{% extends 'base.html' %}

{% load i18n %}
{% load custom_url_tags %}
{% load custom_translation %}

{% block title %}
{% if not run %}
{% trans "KataGo - Contributors" %}
{% else %}
{% blocktrans with run_name=run.name %} KataGo - Contributors for {{run_name}} {% endblocktrans %}
{% endif %}
{% endblock %}

{% block content %}

<h1 class="title">{% blocktrans with run_name=run.name %}Contributors for {{run_name}}{% endblocktrans %}</h1>

{% url 'contributions' current_run.name as current_url %}
{% url 'runs' as older_url %}
{% include 'handle_multiple_runs.html' %}

{% if top_recent_user_list|length > 0 %}
<h5 class="is-size-5 mt-4"> {% trans "Top contributors this run in the last week:" %} </h5>

<table class="table mt-2">
  <tr>
    <th> {% trans "User" %} </th>
    <th class="has-text-right"> {% trans "Training Rows" %} </th>
    <th class="has-text-right"> {% trans "Training Games" %} </th>
    <th class="has-text-right"> {% trans "Rating Games" %} </th>
  </tr>
  {% for user in top_recent_user_list %}
  <tr>
    <td> {{ user.username }} </td>
    <td class="has-text-right"> {{ user.total_num_training_rows|as_n_training_rows_str }} </td>
    <td class="has-text-right"> {{ user.total_num_training_games|as_n_training_games_str }} </td>
    <td class="has-text-right"> {{ user.total_num_rating_games|as_n_rating_games_str }} </td>
  </tr>
  {% endfor %}
</table>
{% endif %}

<h5 class="is-size-5 mt-4"> {% trans "All contributors this run across all time:" %} </h5>

<table class="table mt-2">
  <tr>
    <th> {% trans "User" %} </th>
    <th class="has-text-right"> {% trans "Training Rows" %} </th>
    <th class="has-text-right"> {% trans "Training Games" %} </th>
    <th class="has-text-right"> {% trans "Rating Games" %} </th>
  </tr>
  {% for user in all_time_user_list %}
  <tr>
    <td> {{ user.username }} </td>
    <td class="has-text-right"> {{ user.total_num_training_rows|as_n_training_rows_str }} </td>
    <td class="has-text-right"> <a href="{% training_games_list_by_user user.username %}"> {{ user.total_num_training_games|as_n_training_games_str }} </td>
    <td class="has-text-right"> <a href="{% rating_games_list_by_user user.username %}"> {{ user.total_num_rating_games|as_n_rating_games_str }} </td>
  </tr>
  {% endfor %}
</table>

{% endblock content %}
